const allGender = [["男","爷"],["女","奶"],]
const allDisabilityType=["未获得","儿麻后遗症", "骨关节疾患", "畸形", "脊柱脊髓伤病", "截/缺肢", "截瘫", 
  "精神", "脑瘫", "偏瘫", "视力", "听力", "言语", "肢体", "智力", "周围神经损伤"
  ]
const allDisabilityCause = ["未获得","产伤", "创伤或意外伤害", "发育畸形", "感染", "骨关节病", "疾病", "脊髓灰质炎",
 "脊髓损伤", "交通事故", "脑性瘫痪", "脑血管疾病", "其他外伤", "先天性损伤或发育障碍", "原因不明", 
 "早产", "窒息", "中毒"]
const allDisabilityLevel = ["未定级","一级","二级","三级","四级"]
const allBehaviorPhase = ["未评估","初次","中期","末期"]
const ages = []
function toChinesNum(num){
  let changeNum = ['','一', '二', '三', '四', '五', '六', '七', '八', '九', '十']
  let text = ''
  if (num < 10){
    text = changeNum[num]
  }else if (num < 20){
    text = '十' + changeNum[num % 10]
  }else if(num < 100){
    text = changeNum[parseInt(num / 10)] + '十' + changeNum[num % 10]
  }else{
    text = '一百'
  }
  return text
}
for (let i = 1; i <= 100; i++) {
  ages.push(toChinesNum(i))
}
export default(item, query) => {
  switch(item){
    case "Gender":
      for(let i = 0; i<allGender.length; i++){
        for(let j = 0; j<allGender[i].length; j++){
          if(query.search(allGender[i][j]) != -1)
            return allGender[i][0]
        }
      }
      return "no";
      break;
    case "Age":
      for(let i = 99; i>0; i--){
        if(query.search(ages[i]) != -1){
          console.log(ages[i])
          return i+1
        }
      }
      return "no";
      break;
    case "DisabilityType":
      for(let i = 0; i<allDisabilityType.length; i++){
        if(query.search(allDisabilityType[i]) != -1)
          return allDisabilityType[i]
      }
      return "no";
      break;
    case "DisabilityCause":
      for(let i = 0; i<allDisabilityCause.length; i++){
        if(query.search(allDisabilityCause[i]) != -1)
          return allDisabilityCause[i]
      }
      return "no";
      break;
    case "DisabilityLevel":
      for(let i = 0; i<allDisabilityLevel.length; i++){
        if(query.search(allDisabilityLevel[i]) != -1)
          return allDisabilityLevel[i]
      }
      return "no";
      break;
    case "BehaviorPhase":
      for(let i = 0; i<allBehaviorPhase.length; i++){
        if(query.search(allBehaviorPhase[i]) != -1)
          return allBehaviorPhase[i]
      }
      return "no";
      break;
  }
}
